package com.metacube.questionbank.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;

import com.metacube.questionbank.dto.UserDTO;

public class UserExtractor implements ResultSetExtractor<UserDTO>{
	
	UserDTO userDTO = new UserDTO();
	
	 public UserDTO extractData(ResultSet resultSet) throws SQLException,
	   DataAccessException {

	  userDTO.setId(resultSet.getInt("USERID"));
	  userDTO.setName(resultSet.getString("NAME"));
	  userDTO.seteMail(resultSet.getString("EMAIL"));
	  userDTO.setPassword(resultSet.getString("PASSWORD"));
	  userDTO.setOrganisation(resultSet.getString("ORGANISATION"));
	  userDTO.setPosition(resultSet.getString("POSITION"));
	  userDTO.setLocation(resultSet.getString("LOCATION"));
	  userDTO.setPhotoURL(resultSet.getString("PHOTOURL"));
	  userDTO.setPoints(resultSet.getInt("POINTS"));
	  userDTO.setIsActive(resultSet.getInt("ISACTIVE")); 
	  
	  return userDTO;
	 }

}
